﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Koonsoft.HYCRM.DAL
{
    public class TasksDesignateDAL
    {
        private static readonly Database database = DatabaseFactory.CreateDatabase("KOONCRMDB");

        public bool DesignateTaskToEmpolyee(int taskID, int empolyeeID,int branchID,int managerID)
        {
            const string sql = @"insert into TasksDesignated (taskid,designateID,designateDate,branchID,
                                manageID,[status]) values (@taskid,@designateID,getdate(),@branchID,@manageID,0)";

            using (var cmd = database.GetSqlStringCommand(sql))
            {
                database.AddInParameter(cmd,"@taskid",DbType.Int32,taskID);
                database.AddInParameter(cmd, "@designateID", DbType.Int32, empolyeeID);
                database.AddInParameter(cmd, "@branchID", DbType.Int32, branchID);
                database.AddInParameter(cmd, "@manageID", DbType.Int32, managerID);

                return database.ExecuteNonQuery(cmd) == 1;
            }
        }
    }
}
